stage.set_background("schoolentrance")
sprite = codesters.Sprite("cheerleader4")
sprite.move_down(150)
stage.wait(2)
sprite.turn_right(360)
def click(sprite):
sprite.say("Remember to social distance!")
sprite.set_x_speed(5)
sprite.event_click(click)
t = codesters.Teacher()
try:
tval1 = stage.get_background()
except:
tval1 = "DNE"
try:
tval2 = sprite.get_image_name()
except:
tval2 = "DNE"
try:
tval3x = sprite.get_x()
tval3y = sprite.get_y()
except:
tval3x = "DNE"
tval3y = "DNE"
try:
tval4 = len(t.find_function('turn_right'))
except:
tval4 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 != "schoolentrance" or tval2 != 'cheerleader4', "Great job!")
t1.add_failure(tval2 == "DNE", "Oops! Did you delete your sprite?")
t1.add_failure(tval1 == None, "Oops! Did you delete your background?")
t1.add_failure(tval1 == 'schoolentrance' and tval2 == 'cheerleader4', "Make sure you complete Requirement #1!")
t2 = TestObjective()
t2.add_success(tval3x != 0 or tval3y != -150, "Great job!")
t2.add_failure(tval3x == "DNE" or tval3y == "DNE", "Oops! Did you delete your sprite?")
t2.add_failure(tval3x == 0 and tval3y == -150, "Make sure you complete Requirement #2!")
t3 = TestObjective()
t3.add_success(tval4 > 1, "Great job!")
t3.add_failure(tval4 <= 1, "Did you add another Turn Right command?")
t3.add_failure(tval4 == "DNE", "Did you delete any Turn Right commands?")
tester = TestManager()
tester.add_test_list([t1, t2, t3])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)